package com.zy.pro.order.web;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zy.core.model.PageView;
import com.zy.core.web.BaseController;
import com.zy.pro.order.model.OrderMoney;
import com.zy.pro.order.service.OrderMoneyService;
import com.zy.pro.order.web.form.OrderMoneySearchForm;
/**
 * 订单付款记录管理控制器
 *
 */
@Controller
@RequestMapping("/control/order/orderMoneyController")
public class OrderMoneyController extends BaseController {

	private static final Logger logger = Logger.getLogger(OrderMoneyController.class);
	
	/**
	 * 订单付款记录管理服务类
	 */
	@Resource(name = "orderMoneyServiceImpl")
	private OrderMoneyService orderMoneyService;
	
	/**
	 * 列出订单付款记录管理
	 */
	@RequestMapping("/list")
	public String list(OrderMoneySearchForm form, ModelMap map) {
		try {
			//设置查询排序
			//TODO eg:form.getOrderby().put("id", "asc");
			
			
			//创建页面对象
			PageView<OrderMoney> pageView = new PageView<OrderMoney>(12, form.getPage());
			form.setFirstResult(pageView.getFirstResult());
			form.setMaxResult(pageView.getMaxresult());
			pageView.setQueryResult(orderMoneyService.getData(form));
			map.addAttribute("pageView", pageView);
			map.addAttribute("form", form);
			//TODO 转发页面
			return "";
		} catch(Exception e){
			logger.error(e);
			return "error";
		}
	}
	
	/**
	 * 显示添加订单付款记录管理
	 */
	@RequestMapping("/displayAdd")
	public String displayAdd(OrderMoney orderMoney, ModelMap map) {
		try {
			//TODO 加载显示页面数据
			
			
			//TODO 转发页面
			return "";
		} catch(Exception e){
			logger.error(e);
			return "error";
		}
	}
	
	/**
	 * 添加订单付款记录管理
	 */
	@RequestMapping("/add")
	public String add(OrderMoney orderMoney, ModelMap map) {
		try {
			//TODO 设置orderMoney  eg:主键信息
			
			orderMoneyService.save(orderMoney);
			return list(new OrderMoneySearchForm(), map);
		} catch(Exception e){
			logger.error(e);
			return "error";
		}
	}
	
	/**
	 * 显示编辑订单付款记录管理
	 */
	@RequestMapping("/displayEdit")
	public String displayEdit(OrderMoneySearchForm form, ModelMap map) {
		try {
			//TODO 查询对象
			//eg:OrderMoney orderMoney = orderMoneyService.find(form.getId());
			//eg:map.addAttribute("entity", orderMoney);
			
			
			//TODO 转发页面
			return "";
		} catch (Exception e) {
			logger.error(e);
			return "error";
		}
	}
	
	/**
	 * 编辑订单付款记录管理
	 */
	@RequestMapping("/edit")
	public String edit(OrderMoney OrderMoney, ModelMap map) {
		try {
			//TODO:处理订单付款记录管理
			
			
			orderMoneyService.updateBySelective(OrderMoney);
			return list(new OrderMoneySearchForm(), map);
		} catch (Exception e) {
			logger.error(e);
			return "error";
		}
		
	}

	/**
	 * 删除单个订单付款记录管理
	 */
	@RequestMapping("/deleteorderMoney")
	public String delete(OrderMoneySearchForm form, ModelMap map) {
		try {
			//TODO  eg:orderMoneyService.delete(form.getId());
			
			return list(form, map);
		} catch (Exception e) {
			logger.error(e);
			return "error";
		}
	}
	
	/**
	 * 批量删除订单付款记录管理
	 */
	@RequestMapping("/batchDelete")
	public String deletes(OrderMoneySearchForm form, ModelMap map) {
		try {
//			TODO  eg:orderMoneyService.batchDelete(form.getIds());
			
			return list(form, map);
		} catch (Exception e) {
			logger.error(e);
			return "error";
		}
	}
}
